package cn.myjerry.thread.status;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 倒计时
 * 1、倒计10个数
 * 2、倒计时
 * @author Jerry
 *
 */

public class SleepDemo01 {
	public static void main(String[] args) throws InterruptedException {
		Date endDate = new Date(System.currentTimeMillis() + 10 * 1000);
		long end = new Date().getTime();
		while(true) {
			System.out.println(new SimpleDateFormat("mm:ss").format(endDate));
			Thread.sleep(1000);
			endDate = new Date(endDate.getTime() - 1000);
			if(endDate.getTime() < end - 1000) {
				break;
			}
		}
	}
	public static void test01() throws InterruptedException {
		int num = 10;
		while(true) {
			System.out.println(num--);
			Thread.sleep(1000);
			if(num <= 0) {
				break;
			}
		}
	}
}
